<jsp:include page="../../header.jsp">
			<jsp:param value="item4" name="item"/>
</jsp:include> 
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% String almessage = null;
if(request.getAttribute("almessage")!=null){
almessage = request.getAttribute("almessage").toString();
out.print("<script>alert('"+almessage+"')</script>");
}%>

<section class="content">
	<section class="widget"  id="department" >
		<header>
			<span class="icon">&#128196;</span>
			<hgroup>
				<h1>审核信息表</h1>
				<h2>信息列表</h2>
			</hgroup>
		</header>
		<div class="content">
 <div id="bottomTabs" class="tabs" >
	<ul>
    	<li class="on">出差审核</li>
    	<li>报销审核</li>
    </ul>
    <div class="show">
    <s:if test="businessTravelLists!=null&&businessTravelLists.size()!=0">
    <form action="verifierAction!alterListByStatus.action" name="businessTravelLists" method="post">
    	<table id="myTable">
		<tr>
			<th>选择</th>
			<th>出差单号</th>
			<th>职工号</th>
			<th>职工姓名</th>
			<th>开始时间</th>
			<th>结束时间</th>
			<th>预算/元</th>
			<th>状态</th>
			<th>审批人</th>
		</tr>
		<s:iterator value="businessTravelLists" id="row" status="state">
			<tr>
			<td><s:checkbox name="check" fieldValue="%{#row.travelOrder}" id="%{#state.index+1}"/></td>
				<td>
				<input type="hidden"  name="#row.travelOrder" 
					value="<s:property value="#row.travelOrder"/>">
				<a  href="<s:url action='verifierAction!getTravelsByOrder.action?travelOrder=%{#row.travelOrder}' />">
					<s:property  value="#row.travelOrder"/></a>
				</td>
				 <td>
					<label name="#row.userInfoByUserid.userid"><s:property value="#row.userInfoByUserid.userid"/></label>
				</td>
				<td>
					<label name="#row.userInfoByUserid.userName"><s:property value="#row.userInfoByUserid.userName"/></label>
				</td>
				<td>
					<label name="#row.startTime"><s:date name="#row.startTime" format="yyyy-MM-dd" /></label>
				</td>
				<td>
					<label name="#row.endTime">
					<s:date name="#row.endTime" format="yyyy-MM-dd" /></label>
				</td>
				<td>
					<label name="#row.amount"><s:property value="#row.amount"/></label>
				</td>
				<td>
				<!--  jsp页面遍历List集合,修改后将集合传到action中 -->
					<select name='businessTravelLists[<s:property value="#state.index"/>].verifierStatus' onchange="modify(this)" dataID=<s:property value="#state.index+1"/>>
						<option value="待审核">待审核</option>
						<option value="审核不通过">审核不通过</option>
						<option value="审核通过">审核通过</option>
					</select>
				</td>
				<td>
				<input type="hidden"  name="#row.userInfoByVerifierId.userid" 
					value="<s:property value="#row.userInfoByVerifierId.userid"/>">
					<label name="#row.userInfoByVerifierId.userName"><s:property value="#row.userInfoByVerifierId.userName"/></label>
				</td>
			</tr>
		</s:iterator>
	</table>
	<input type="submit" id="submit" class="white" value="提交" onclick="return makesure()">
	</form>
	</s:if>
	<s:else>
		<h3>没有待审核的出差申请</h3>
	</s:else>
    </div>
    <div class="hide">
    	<s:if test="businessApplayReims!=null&&businessApplayReims.size()!=0">
    	 <form action="verifierAction!alterListByStatus.action" name="businessApplayReims" method="post">
    		 <table id="myTable">
		<tr>
			<th>选择</th>
			<th>报销单号</th>
			<th>职工号</th>
			<th>职工姓名</th>
			<th>预算/元</th>
			<th>申请报销/元</th>
			<th>实际报销/元</th>
			<th>节省/元</th>
			<th>状态</th>
			<th>审批人</th>
		</tr>
		<%int i = 0; %>
		<s:iterator value="businessApplayReims" id="row" status="sta"></section>
		
			<tr>
			<td><s:checkbox name="check" fieldValue="%{#row.travelOrder}" id="a%{#sta.index+1}"/></td>
				<td>
				<input type="hidden" name="#row.travelOrder" 
				value='<s:property value="#row.travelOrder"/>'>
				<a href="<s:url action='verifierAction!getTravelInfoList.action?travelOrder=%{#row.travelOrder}' />">
					<s:property value="#row.travelOrder"/></a>
				</td>
				 <td>
				 <label name="#row.userInfoByUserid.userid">
				 	<s:property value="#row.userInfoByUserid.userid"/>
				 </label>
				</td>
				<td>
					<input type="hidden" name="#row.startTime" value='<s:date name="#row.startTime" format="yyyy-MM-dd" />'>
					<input type="hidden" name="#row.endTime" value='<s:date name="#row.endTime" format="yyyy-MM-dd" />'>
					<label name="#row.userInfoByUserid.userName">
					 	<s:property value="#row.userInfoByUserid.userName"/>
					 </label>
				</td>
				<td>
				<input type="hidden" name="#row.amount"  id='<%="amount"+String.valueOf(i)%>'
						value=<s:property value="#row.amount"/>>
					<s:property value="#row.amount"/>
				</td>
					<td>
						<s:property value="#row.applayReim.appAmount"/>
					</td>
					<td>
					<input type="text" name="businessApplayReims[<s:property value="#sta.index"/>].applayReim.realAppAmount"  id='<%="realAppAmount"+String.valueOf(i)%>'  
					onchange="countSavecost('<s:property value="#sta.index"/>',this)" dataID='a<s:property value="#sta.index+1"/>'
					maxlength="12"  onkeyup="this.value = this.value.replace(/[^\d.]/g,'')"  onafterpaste="this.value=this.value.replace(/[^\d.]/g,'')" 
					value=<s:property value="#row.applayReim.realAppAmount"/>>
					</td>
					<td>
					<input type="text" name="businessApplayReims[<s:property value="#sta.index"/>].applayReim.saveCost" readonly  id='<%="saveCost"+String.valueOf(i)%>'  
						value=<s:property value="#row.applayReim.saveCost"/>>
					</td>
					<%i++; %>
				<td>
					<select name='businessApplayReims[<s:property value="#sta.index"/>].verifierStatus' onchange="modify(this)" dataID='a<s:property value="#sta.index+1"/>'>
						<option value="待报销">待报销</option>
						<option value="已报销">已报销</option>
						<option value="报销不通过">报销不通过</option>
					</select>
				</td>
				<td>
				<input type="hidden"  name="#row.userInfoByVerifierId.userid" 
					value="<s:property value="#row.userInfoByVerifierId.userid"/>">
					<label name="#row.userInfoByVerifierId.userName"><s:property value="#row.userInfoByVerifierId.userName"/></label>
				</td>
			</tr>
		</s:iterator>
	</table>
	<input type="submit" id="submit" class="white"   value="提交" onclick="return makesure()">	
    </form>
    	</s:if>
    	<s:else>
    	<h3>没有待审核的报销申请</h3>
    	</s:else>
    </div>
    </div>
    </div>
    </section>
    <script type="text/javascript">
 	function resizeInput() {
 		$(this).attr('size', $(this).val().length);
	}
	$("input[type=text]").each(resizeInput);
	
	
    function modify(obj){
	    	var dataID;
    		if(obj.dataID){
    			dataID=obj.dataID;
    		}else if(obj.getAttribute){
    			dataID=obj.getAttribute("dataID");
    		}else{
    			dataID=null;
    		}
	    
	    	var checkbox =document.getElementById(dataID);
	    	checkbox.checked="checked";
	    	
	    }
	    //计算节省费用
	function countSavecost(index,obj){
	
		modify(obj);
		var realAppAmount = document.getElementById("realAppAmount"+index).value;
		var amount = document.getElementById("amount"+index).value;
		
		if((/^-?\d+\.?\d{0,2}$/.test(realAppAmount))){
			if(realAppAmount == 0){
				realAppAmount=0;
			}
			var saveCost = amount- realAppAmount;
			document.getElementById("realAppAmount"+index).value = realAppAmount;
			document.getElementById("saveCost"+index).value = saveCost;
		}
		else{
		alert("请输入范围在000000000.00~999999999.99的至多两位小数的数字");
			document.getElementById("realAppAmount"+index).value = 0;
			document.getElementById("saveCost"+index).value  = amount;
			return false;
		}
			
	}
	function makesure(){
	var id = document.getElementsByName('check');
	
		for(var i =0;i<id.length;i++){
			if(id[i].checked)
				return true;
		}
		alert("请勾选修改项！");
		return false;
	}
	</script>
<%@ include file="../../footer.jsp" %>
